#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>

std::vector<int> a;
int n;

int main()
{
	int T; std::cin >> T;
	while (T--) {
		std::cin >> n;
		a.resize(n);
		int p = 0, max = 0;
		for (int i = 0; i < n; i++) {
			std::cin >> a[i];
			if (a[i] > max) {
				max = a[i];
				p = i + 1;
			}
		}
		std::sort(a.begin(), a.end(), std::greater<int>());
		std::cout << p << ' ' << a[1] << '\n';
	}
}

